﻿Public Class ConfigListItem

    Enum ConfigListItemStyle
        Checkbox
        Combobox
        Textbox
    End Enum

    Public Property Style As ConfigListItemStyle
        Get
            Return style_
        End Get
        Set(value As ConfigListItemStyle)
            style_ = value
            Select Case value
                Case ConfigListItemStyle.Checkbox
                    CheckBox.Visible = True
                    ComboBox.Visible = False
                    TextBox.Visible = False
                Case ConfigListItemStyle.Combobox
                    CheckBox.Visible = False
                    ComboBox.Visible = True
                    TextBox.Visible = False
                Case ConfigListItemStyle.Textbox
                    CheckBox.Visible = False
                    ComboBox.Visible = False
                    TextBox.Visible = True
            End Select
        End Set
    End Property

    Private style_ As ConfigListItemStyle

    Public Property Value As String
        Get
            Select Case style_
                Case ConfigListItemStyle.Checkbox
                    Return If(CheckBox.Checked, "true", "false")
                Case ConfigListItemStyle.Combobox
                    Return ComboBox.Text
                Case ConfigListItemStyle.Textbox
                    Return TextBox.Text
                Case Else
                    Return Nothing
            End Select
        End Get
        Set(value As String)
            Select Case style_
                Case ConfigListItemStyle.Checkbox
                    If value.ToLower = "true" Then
                        CheckBox.Checked = True
                    ElseIf value.ToLower = "false" Then
                        CheckBox.Checked = False
                    End If
                Case ConfigListItemStyle.Combobox
                    ComboBox.Text = value
                Case ConfigListItemStyle.Textbox
                    TextBox.Text = value
            End Select
        End Set
    End Property


    Public Sub New(ByVal t As String, ByVal v As String, ByVal s As ConfigListItemStyle)
        ' この呼び出しはデザイナーで必要です。
        InitializeComponent()
        ' InitializeComponent() 呼び出しの後で初期化を追加します。

        Label.Text = t
        Style = s
        Value = v
    End Sub





    Private Sub CheckBox_Click(sender As Object, e As EventArgs) Handles CheckBox.Click
        If CheckBox.Checked Then
            CheckBox.Text = "true"
        Else
            CheckBox.Text = "false"
        End If
    End Sub
End Class
